import java.sql.*;

public class Venue
{
	public static String venuename = null;
	public static int venueid = 0;
	public static int facilityid = 0;
	public static int capacity = 0;
	public static boolean requirelic = false;
	public static boolean status = false;
	public static boolean new_record = false;

	public Venue(String name, int fid, int cap, boolean req, boolean st)
	{
		new_record = true;
		venuename = name;
		facilityid = fid;
		capacity = cap;
		requirelic = req;
		status = st;
	}

	public Venue(int vid) throws SQLException
	{
		new_record = false;
		venueid = vid;

		Connector conn = new Connector("select * from venue where venueid = '" + venueid + "'");
		ResultSet rs = conn.execute();
		if(rs.first())
		{
			venuename = rs.getString("venuename");
			facilityid = rs.getInt("facilityid");
			capacity = rs.getInt("capacity");
			requirelic = rs.getBoolean("requirelic");
			status = rs.getBoolean("status");
		}
		rs.close();
	}
	
	public static boolean insert() throws SQLException
	{
		if(new_record)
		{
			String sql = "insert into venue values(null,"
						+ "'" + venuename + "',"
						+ facilityid + ","
						+ capacity + ","
						+ requirelic + ","
						+ status + ")";

			Connector conn = new Connector(sql);
			conn.execute_sql();
			
			return true;
		}
		else
			return false;
	}

	public static boolean update() throws SQLException
	{
		if(!new_record)
		{
			String sql = "update venue set "
						+ "venuename='" + venuename + "',"
						+ "facilityid=" + facilityid + ","
						+ "capacity=" + capacity + ","
						+ "requirelic=" + requirelic + ","
						+ "status=" + status
						+ " where venueid='" + venueid + "'";

			Connector conn = new Connector(sql);
			conn.execute_sql();
			
			return true;
		}
		else
			return false;
	}

	public static boolean delete() throws SQLException
	{
		if(!new_record)
		{
			String sql = "delete from venue where venueid='" + venueid + "'";

			Connector conn = new Connector(sql);
			conn.execute_sql();
			
			return true;
		}
		else
			return false;
	}

	public static void setVenueName(String vn)
	{
		venuename = vn;
	}

	public static void setFacilityId(int fid)
	{
		facilityid = fid;
	}

	public static void setCapacity(int cap)
	{
		capacity = cap;
	}

	public static void setRequirelic(Boolean rl)
	{
		requirelic = rl;
	}

	public static void setStatus(Boolean st)
	{
		status = st;
	}

	public static String getVenueName()
	{
		return venuename;
	}

	public static int getFacilityId()
	{
		return facilityid;
	}

	public static int getCapacity()
	{
		return capacity;
	}

	public static Boolean getRequirelic()
	{
		return requirelic;
	}

	public static Boolean getStatus()
	{
		return status;
	}
}
